<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<%@ include file="/common/import.jsp" %>
<script>
  var thsTitle = "标的类型管理";
  var currentPage = 1;
  var objName="variety";
  var currentObjId = "";
</script>
<title>标的类型管理-${sysName }</title>
</head>
<body class="home-template2">
<!-- 正文开始 -->
<div class="searchForm"><form id="varietyList_form">
	<input type="hidden" name="page"  value="1">
	<input type="hidden" name="rows"  value="40">
	标的类型名称：<input type="text" name="varietyName"  value="" /> 
	<a class="easyui-linkbutton"  iconCls="icon-search" onclick="varietyListSearch();">查询</a>
	<a class="easyui-linkbutton"  onclick="clearFormById('varietyList_form');">清空</a>
	
	<a class="easyui-linkbutton"  iconCls="icon-add" onclick="addOPen();">增加新品种</a>
</form></div>
<table id="varietyList_table" class="info" cellspacing="1" cellpadding="0">
	<tr class='active' id="title2" >
		<th width='8%'>品种标识</th>
		<th width='20%'>品种简称</th>
		<th width='13%'>创建时间</th>
		<th width='13%'>修改时间</th>			
		<th width='15%'>操作</th>
	</tr>
</table>
<div id="varietyList_page" class="page"></div>
<script type="text/template" id="varietyList_html">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr>
			<td><?=rows[i].varietyCode?></td>
			<td><?=rows[i].varietyName?></td>
			<td><? if (null != rows[i].createTime && rows[i].createTime !="" ) {?><?=rows[i].createTime?><?}?></td>
			<td><? if (null != rows[i].modifyTime && rows[i].modifyTime !="" ) {?><?=rows[i].modifyTime?><?}?></td>
			<td>
				<a class="mybutton"  onclick="editOpen('<?=rows[i].varietyId?>');">修改</a> ||
				<a class="mybutton"  onclick="del('<?=rows[i].varietyId?>');">删除</a>
			</td>
		</tr>
   <?}?>  		
</script>

<div class="easyui-dialog" id="add_window" title="增加品种" closed="true" modal="true" style="width:700px;height:250px;top:50px;">
	<form id="addForm">
		<input type="hidden" name="varietyId" id="varietyId" value="">
		<table class="info" cellspacing="1" cellpadding="0">
		<tr>
			<th>品种标识：<font color="red">*</font></th>
			<td><input type="text" name="varietyCode"  required="true" class="easyui-validatebox validatebox-text" maxlength="10" value="1" size="30"/></td>
		</tr>
		<tr>
			<th>品种名称：<font color="red">*</font></th>
			<td><input type="text" name="varietyName"  required="true" class="easyui-validatebox validatebox-text" value="" size="30" maxlength="30"/></td>
		</tr>
		<tr>
			<td colspan="2" style="text-align:center;">		
			<a class="easyui-linkbutton" id="addButton" iconCls="icon-add" onclick="saveServer();">保存信息</a>
			</td>
		</tr>
		</table>
	</form>
</div>
<!-- 正文结束 -->
<%//@ include file="/common/top.jsp" %>

</body>
</html>

<script>

//查询提交
function varietyListSearch(){
	searchSubmit(objName,"varietyList");
}
function addOPen(){
    clearFormById("addForm");
    //清除form表单未清除hidden值，所以这里手动清除
    $("#varietyId").val("");
    $("#add_window").panel({title:"增加品种"});
	$("#add_window").dialog('open');
}

//提交表单
function saveServer(){
	var varietyId = $("#varietyId").val();
	if(varietyId==""){
		//新增一条记录
		addSubmit(objName,'addForm');
	}else{
		//修改
		editSubmit(objName,varietyId,"addForm");
	}
}
//新增后回调方法
function addCallBack(flag,msg,objName){
	if(flag=="T"){
		varietyListSearch();
	}else{
		alert(msg);
	}
	clearFormById("addForm");
	$("#add_window").dialog('close');
	
}

function getCallBack(flag,obj){
	if("T"==flag){
		loadData(obj,"addForm");
		$("#add_window").dialog('open');
	}else{
		alert("查询失败");
	}
}

//打开更新页面
function editOpen(objId){
    clearFormById("addForm");
	currentObjId=objId;
	$("#add_window").panel({title:"修改品种"});
	getObj(objName,objId);
}

//更新后回调方法
function editCallBack(flag,objName){
	if(flag=="T"){
		varietyListSearch();
	}else{
		alert("删除失败！");
	}
	clearFormById("addForm");
	$("#add_window").dialog('close');
}

//删除
function del(objId){
	if(confirm("确定要删除吗？")){
		delSubmit(objName,objId);
	}
}
//删除后回调方法
function delCallBack(flag,objName){
	if(flag=="T"){
		varietyListSearch();
	}else{
		alert("删除失败！");
	}
}


//初始化加载
$(function(){
	//加载分页列表
	varietyListSearch();
});

</script>

